package com.formulas.certification.web;

import com.formulas.certification.CertificationConstants;
import com.formulas.certification.api.OauthClientDetailsServiceI;
import com.formulas.certification.dto.OauthClientDetailsDeleteCmd;
import com.formulas.certification.dto.OauthClientDetailsInsertCmd;
import com.formulas.certification.dto.OauthClientDetailsQry;
import com.formulas.certification.dto.OauthClientDetailsUpdateCmd;
import com.formulas.certification.dto.data.OauthClientDetailsDTO;
import com.formulas.component.dto.PageResponse;
import com.formulas.component.dto.Response;
import com.formulas.component.extension.BizScenario;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/oauth/client-details")
@Tag(name = "授权客户端应用信息表管理",description = "OauthClientDetailsController")
public class OauthClientDetailsController {

    @Resource
    private OauthClientDetailsServiceI oauthClientDetailsServiceI;

    @Operation(summary = "分页查询客户端应用")
    @PostMapping("/query/OauthClientDetailsPageList")
    public PageResponse<OauthClientDetailsDTO> queryOauthClientDetailsPageList(@RequestBody OauthClientDetailsQry oauthClientDetailsQry) {
        oauthClientDetailsQry.setBizScenario(BizScenario.valueOf(CertificationConstants.BIZ_1));
        return oauthClientDetailsServiceI.queryOauthClientDetailsPageList(oauthClientDetailsQry);
    }

    @Operation(summary = "新增客户端应用")
    @PostMapping("/insert/OauthClientDetails")
    public Response insertOauthClientDetails(@RequestBody OauthClientDetailsInsertCmd oauthClientDetailsInsertCmd) {
        oauthClientDetailsInsertCmd.setBizScenario(BizScenario.valueOf(CertificationConstants.BIZ_1));
        return oauthClientDetailsServiceI.insertOauthClientDetails(oauthClientDetailsInsertCmd);
    }

    @Operation(summary = "编辑客户端应用")
    @PutMapping("/update/OauthClientDetails")
    public Response updateOauthClientDetails(@RequestBody OauthClientDetailsUpdateCmd oauthClientDetailsUpdateCmd) {
        oauthClientDetailsUpdateCmd.setBizScenario(BizScenario.valueOf(CertificationConstants.BIZ_1));
        return oauthClientDetailsServiceI.updateOauthClientDetails(oauthClientDetailsUpdateCmd);
    }

    @Operation(summary = "根据客户端唯一标识删除客户端应用")
    @DeleteMapping("/delete/OauthClientDetailsByClientId")
    public Response deleteOauthClientDetailsByClientId(@RequestBody OauthClientDetailsDeleteCmd oauthClientDetailsDeleteCmd) {
        oauthClientDetailsDeleteCmd.setBizScenario(BizScenario.valueOf(CertificationConstants.BIZ_1));
        return oauthClientDetailsServiceI.deleteOauthClientDetailsByClientId(oauthClientDetailsDeleteCmd);
    }
}
